﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using UnityEngine;
using UnityEngine.UI;

public class DaLeTou_Pro : ShaHaoSeter
{

    public List<List<int>> envCurData = new List<List<int>>();
    public int ProCount = 1000;
    // Start is called before the first frame update
    protected override void Start()
    {
        uiCompos = GetComponent<UICompos>();
        
        uiCompos["Opens"].GetComps<Button>().onClick.AddListener(() =>
        {
            var content = uiCompos["InputField"].GetComps<InputField>().text;
            content = content.Replace(" ", "");
            content = content.Replace('，', ',');
            content = content.Replace('.', ',');
            content = content.Replace('、', ',');
            
            var sp_content = content.Split(',');

            List<int> input_nums = new List<int>();
            for (int i = 0; i < sp_content.Length; i++)
            {
                var ngnum = sp_content[i].Trim();
                int ret = -1;
                // 2,8,9,4,5,8,9,1,2,9
                // 1,3,4,5
                if (!int.TryParse(ngnum, out ret))
                {
                    continue;
                }

                input_nums.Add(ret);
            }

            if (input_nums.Count <= 0)
            {
                return;
            }
            
            

        });
    }

    public virtual List<List<int>>  Duplex2SingeNote(List<List<int>> input_nums_array)
    {
        var datas = new List<List<int>>();

        #region 大复式组合成单注

        for (int j = 0; j < input_nums_array.Count; j++)
        {
            List<int> input_nums = input_nums_array[j];
            var max = input_nums.Count;
            for (int i = 1; i <= max - 4; i++)
            {
                for (int i2 = i + 1; i2 <= max - 3; i2++)
                {
                    for (int i3 = i2 + 1; i3 <= max - 2; i3++)
                    {
                        for (int i4 = i3 + 1; i4 <= max - 1; i4++)
                        {
                            for (int i5 = i4 + 1; i5 <= max; i5++)
                            {
                                datas.Add(new List<int>()
                                {
                                    input_nums[i - 1], input_nums[i2 - 1], input_nums[i3 - 1],
                                    input_nums[i4 - 1],
                                    input_nums[i5 - 1],
                                });
                            }
                        }
                    }
                }
            }
        }

        #endregion

        return datas;
    }
    
    void Test()
    {
        OpenFileName openFileName = new OpenFileName();
        openFileName.structSize = Marshal.SizeOf(openFileName);
        openFileName.filter = "*.*";
        openFileName.file = new string(new char[256]);
        openFileName.maxFile = openFileName.file.Length;
        openFileName.fileTitle = new string(new char[64]);
        openFileName.maxFileTitle = openFileName.fileTitle.Length;
        openFileName.initialDir = (Application.dataPath + "/../").Replace('/','\\');//默认路径
        openFileName.title = "窗口标题";
        openFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

        if (LocalDialog.GetSaveFileName(openFileName))
        {
            Debug.Log(openFileName.file);
            Debug.Log(openFileName.fileTitle);
        }
        else
        {
            Debug.Log("-------------->>>>>");
        }
    }
}
